﻿////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// <copyright>Copyright 2008-2011 Andreas Huber Doenni</copyright>
// Distributed under the Microsoft Public License (Ms-PL).
// See accompanying file License.txt or copy at http://mews.codeplex.com/license.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

namespace Mews.Application
{
    using System;
    using System.Windows.Forms;

    /// <summary>The base class of all forms that have Done &amp; Cancel menu items.</summary>
    /// <remarks>This class must be public and non-abstract so that deriving forms can be designed.</remarks>
    public partial class DoneCancelForm : TitleForm
    {
        /// <summary>Initializes a new instance of the <see cref="DoneCancelForm"/> class.</summary>
        /// <remarks>This constructor must remain public so that deriving forms can be designed.</remarks>
        public DoneCancelForm()
        {
            this.InitializeComponent();
        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        internal DoneCancelForm(
            Form owner, string title, bool showMinimizeBox, bool hideDoneButton, bool hideCancelButton) :
            base(owner, title, showMinimizeBox)
        {
            this.InitializeComponent();

            if (hideDoneButton)
            {
                this.mainMenu.MenuItems.Remove(this.doneMenuItem);
            }

            if (hideCancelButton)
            {
                this.mainMenu.MenuItems.Remove(this.cancelMenuItem);
            }
        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        private void OnDoneMenuItem_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void OnCancelMenuItem_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
    }
}